package com.glodon.paas.job.agent.mq;

import static com.glodon.paas.job.JobConstants.*;

import com.glodon.paas.job.agent.Agent;
import com.glodon.paas.job.agent.worker.Caller;
import com.glodon.paas.job.model.Task;

public class JmsCaller implements Caller {
    private Agent agent;
    private Task task;

    public JmsCaller(Agent agent, Task task) {
        this.agent = agent;
        this.task = task;
    }

    @Override
    public void send() {
        agent.sendMessage(task);
    }

    @Override
    public void sendProgress(int progress, String message) {
        task.addValue(TASK_PROGRESS, progress);
        task.addValue(TASK_MESSAGE, message);
        send();
    }
}
